﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>读取cookie</title>
  </head>
  
  <body>
<%
    Cookie[] cookies = request.getCookies();
    boolean sign = false; //标识
    if (cookies != null) {
        for (int i=0; i<cookies.length; i++) {
            if (cookies[i].getName().equals("info")) {
                sign = true;
                out.print("读取Cookie的值:" + cookies[i].getValue());
            }
        }
    }
    if (!sign) {
        out.print("超过Cookie有效期,无法读取Cookie");
    }
%>
  </body>
</html>
